<?php
/* Driver template for the LEMON parser generator.
** The author disclaims copyright to this source code.
*/

/* Next is all token values, in a form suitable for use by makeheaders.
** This section will be null unless lemon is run with the -m switch.
*/
/* 
** These constants (all generated automatically by the parser generator)
** specify the various kinds of tokens (terminals) that the parser
** understands. 
**
** Each symbol here is a terminal symbol in the grammar.
*/

/*
** This class is used for all minor tokens.
*/
class Parser_Minor {
	public $yy0;
	public $yy165;

	public function __construct() {
		$this->yy0 = new stdClass();
	}
}


/* The following class represents a single element of the
** parser's stack.  Information stored includes:
**
**   +  The state number for the parser at this level of the stack.
**
**   +  The value of the token stored at this level of the stack.
**      (In other words, the "major" token.)
**
**   +  The semantic value stored at this level of the stack.  This is
**      the information used by the action routines in the grammar.
**      It is sometimes called the "minor" token.
*/
class Parser_StackEntry {
	/**
	 * @var int $stateno The state-number
	 */
	public $stateno;
	
	/**
	 * @var int $major The major token value.  
	 *
	 * This is the code number for the token at this stack level 
	 */
	public $major;     
	
	/**
	 * @var Parser_Minor $minor The user-supplied minor token value.
	 *
	 * This is the value of the token
     */
	public $minor;
	
	function Parser_StackEntry() {
		$this->minor = new Parser_Minor();
		$this->stateno = 0;
		$this->major = 0;
	}
		
}

class Parser_Stack {

	private $stack;
	
	function Parser_Stack() {
		$this->stack = array();
	}
	
	/**
	 * Returns the top of this stack
	 *
	 * @return Parser_StackEntry
	 */
	function getTop() {
		return $this->stack[count($this->stack) - 1];
	}
	
	function getBottom() {
		return $this->stack[0];
	}
	
	function getRelative($offset = 0) {
		$i = count($this->stack) - 1;
		return $this->stack[$i + $offset];
	}
	
	/**
	 * Pops elements from the stack
	 *
	 * @param int $i number of elements to pop
	 * @return Parser_StackEntry last popped element
	 */
	function pop($i = 1) {
		for ($x = 0; $x < $i; $x++)
			array_pop($this->stack);	
	}
	
	function push(Parser_StackEntry $entry) {
		array_push($this->stack, $entry);
	}
	
	function size() {
		return count($this->stack);
	}
	
	function getArray() {
		return $this->stack;
	}
}

class Parser {
	
	/* Code is include which follows the "include" declaration
	** in the input file. */
#line 1 "GeryEngine\\lib\\compiler\\Parser\\parser.y"


	private $compileEngine;
	private $referenceOffset;
	private $ast;
	
	public function setCompileEngine(IGeryCompileEngine  $engine) {
		$this->compileEngine = $engine;
	}
	
	/** 
	 * Get the abstract syntax tree
	 *
	 * @return IASTNode The abstract syntax tree
	 */
	public function getAST() {
		return $this->ast;
	}
	
	public function getExpectedTokens() {
		$expected = array();
		
		$stateno = $this->stack->getTop()->stateno;
		
		for ($x = 0; $x < self::YYERRORSYMBOL; $x++) {
			$yyact = $this->yy_find_shift_action($x);
			if ($yyact != self::YY_ERROR_ACTION) {
				if (isset($alias[$x])) {
					$name = "'" . $alias[$x] . "'";
				} else {
					$name = $this->getSymbolName($x);
				}
				
				$expected[] = $name;
			}
		}
		
		return $expected;
	}
#line 161 "GeryEngine\\lib\\compiler\\Parser\\parser.php"

	private $stack;
	private $yyerrcnt;
	
	/* The next thing included is series of constants which control
	** various aspects of the generated parser.
	**    YYNOCODE           is a number which corresponds to no legal terminal
	**                       or nonterminal number.  This number is used to 
	**                       fill in empty slots of the hash table.
	**    YYFALLBACK         If defined, this indicates that one or more tokens
	**                       have fall-back values which should be used if the
	**                       original value of the token will not parse.
	**    YYSTACKDEPTH       is the maximum depth of the parser's stack.
	**    YYNSTATE           the combined number of states.
	**    YYNRULE            the number of rules in the grammar
	**    YYERRORSYMBOL      is the code number of the error symbol.  If not
	**                       defined, then do no error processing.
	*/
	const YYNOCODE			= 83;
	const YYSTACKDEPTH		= 100;
	const YYNSTATE			= 166;
	const YYNRULE			= 84;

	const YYERRORSYMBOL		= 49;
	const YYERRSYMDT		= 'yy165';

	const YY_NO_ACTION		= 252;
	const YY_ACCEPT_ACTION	= 251;
	const YY_ERROR_ACTION	= 250;

	const YYFALLBACK		= 0;

	private $yyRuleInfo = array(
		// array(LHS, NRHS)
		array(50, 1),
		array(51, 1),
		array(52, 2),
		array(52, 0),
		array(53, 1),
		array(53, 2),
		array(53, 2),
		array(53, 1),
		array(53, 1),
		array(58, 1),
		array(58, 1),
		array(55, 1),
		array(55, 1),
		array(61, 3),
		array(63, 0),
		array(59, 6),
		array(60, 7),
		array(65, 3),
		array(65, 1),
		array(65, 0),
		array(66, 5),
		array(66, 2),
		array(64, 2),
		array(64, 0),
		array(68, 3),
		array(67, 3),
		array(67, 1),
		array(67, 0),
		array(62, 0),
		array(62, 1),
		array(54, 1),
		array(54, 0),
		array(69, 3),
		array(69, 3),
		array(69, 3),
		array(69, 3),
		array(69, 3),
		array(69, 3),
		array(69, 3),
		array(69, 2),
		array(69, 3),
		array(69, 3),
		array(69, 3),
		array(69, 3),
		array(69, 3),
		array(69, 3),
		array(69, 3),
		array(69, 1),
		array(69, 1),
		array(69, 1),
		array(69, 1),
		array(69, 3),
		array(70, 1),
		array(70, 1),
		array(73, 1),
		array(73, 1),
		array(71, 3),
		array(74, 1),
		array(74, 3),
		array(75, 3),
		array(75, 1),
		array(75, 0),
		array(76, 1),
		array(76, 3),
		array(56, 8),
		array(77, 6),
		array(77, 0),
		array(78, 2),
		array(78, 0),
		array(56, 6),
		array(56, 4),
		array(79, 3),
		array(79, 1),
		array(56, 9),
		array(56, 1),
		array(56, 4),
		array(56, 4),
		array(56, 1),
		array(72, 4),
		array(56, 1),
		array(80, 7),
		array(81, 2),
		array(81, 0),
		array(57, 4),
	);
	
	/* Next are that tables used to determine what action to take based on the
	** current state and lookahead token.  These tables are used to implement
	** functions that take a state number and lookahead value and return an
	** action integer.  
	**
	** Suppose the action integer is N.  Then the action is determined as
	** follows
	**
	**   0 <= N < YYNSTATE                  Shift N.  That is, push the lookahead
	**                                      token onto the stack and goto state N.
	**
	**   YYNSTATE <= N < YYNSTATE+YYNRULE   Reduce by rule N-YYNSTATE.
	**
	**   N == YYNSTATE+YYNRULE              A syntax error has occurred.
	**
	**   N == YYNSTATE+YYNRULE+1            The parser accepts its input.
	**
	**   N == YYNSTATE+YYNRULE+2            No such action.  Denotes unused
	**                                      slots in the yy_action[] table.
	**
	** The action table is constructed as a single large table named yy_action[].
	** Given state S and lookahead X, the action is computed as
	**
	**      yy_action[ yy_shift_ofst[S] + X ]
	**
	** If the index value yy_shift_ofst[S]+X is out of range or if the value
	** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
	** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
	** and that yy_default[S] should be used instead.  
	**
	** The formula above is for computing the action when the lookahead is
	** a terminal symbol.  If the lookahead is a non-terminal (as occurs after
	** a reduce action) then the yy_reduce_ofst[] array is used in place of
	** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
	** YY_SHIFT_USE_DFLT.
	**
	** The following are the tables generated in this section:
	**
	**  yy_action[]        A single table containing all actions.
	**  yy_lookahead[]     A table containing the lookahead for each entry in
	**                     yy_action.  Used to detect hash collisions.
	**  yy_shift_ofst[]    For each state, the offset into yy_action for
	**                     shifting terminals.
	**  yy_reduce_ofst[]   For each state, the offset into yy_action for
	**                     shifting non-terminals after a reduce.
	**  yy_default[]       Default action for each state.
	*/
	private $yy_action = array(
		/*     0 */    30,   32,   16,   44,   46,   48,   50,   52,   54,   72,
		/*    10 */    34,   36,   38,   40,   42,  147,   56,   30,   32,  166,
		/*    20 */    44,   46,   48,   50,   52,   54,   16,   34,   36,   38,
		/*    30 */    40,   42,  128,   56,  144,   81,   95,  162,   30,   32,
		/*    40 */   142,   44,   46,   48,   50,   52,   54,   29,   34,   36,
		/*    50 */    38,   40,   42,  139,   56,   12,   91,   30,   32,   56,
		/*    60 */    44,   46,   48,   50,   52,   54,   63,   34,   36,   38,
		/*    70 */    40,   42,   26,   56,   57,   58,   30,   32,  138,   44,
		/*    80 */    46,   48,   50,   52,   54,  112,   34,   36,   38,   40,
		/*    90 */    42,   27,   56,  194,   44,   46,   48,   50,   52,   54,
		/*   100 */    22,   34,   36,   38,   40,   42,  224,   56,   20,   30,
		/*   110 */    32,   25,   44,   46,   48,   50,   52,   54,  149,   34,
		/*   120 */    36,   38,   40,   42,  128,   56,  137,  135,   30,   32,
		/*   130 */   134,   44,   46,   48,   50,   52,   54,   99,   34,   36,
		/*   140 */    38,   40,   42,   18,   56,  131,  130,   30,   32,  129,
		/*   150 */    44,   46,   48,   50,   52,   54,  141,   34,   36,   38,
		/*   160 */    40,   42,  220,   56,  221,  151,   30,   32,  127,   44,
		/*   170 */    46,   48,   50,   52,   54,  125,   34,   36,   38,   40,
		/*   180 */    42,  123,   56,   30,   32,   77,   44,   46,   48,   50,
		/*   190 */    52,   54,   59,   34,   36,   38,   40,   42,   20,   56,
		/*   200 */    20,   81,   94,   58,   61,   26,   70,  122,  121,  117,
		/*   210 */    68,   69,   30,   32,   79,   44,   46,   48,   50,   52,
		/*   220 */    54,   74,   34,   36,   38,   40,   42,   32,   56,   44,
		/*   230 */    46,   48,   50,   52,   54,  119,   34,   36,   38,   40,
		/*   240 */    42,  115,   56,   10,   48,   50,   52,   54,   22,   34,
		/*   250 */    36,   38,   40,   42,  153,   56,   96,  120,  126,  136,
		/*   260 */   113,  145,  146,  152,   74,  158,  232,  232,  232,    4,
		/*   270 */   103,  104,  231,  231,  231,    4,  103,  104,   65,   11,
		/*   280 */   155,  105,  118,  234,    4,  103,  104,  105,   31,   64,
		/*   290 */    66,   67,   65,    3,    5,  114,  105,  101,  102,  108,
		/*   300 */    86,  114,   71,   64,   66,   67,   12,   83,   85,   89,
		/*   310 */   114,  167,  110,   75,  233,    4,  103,  104,   34,   36,
		/*   320 */    38,   40,   42,   18,   56,    6,    7,  105,   27,    8,
		/*   330 */     9,  223,   77,    4,  103,  104,   65,  251,    1,    2,
		/*   340 */    90,  114,  156,   21,   76,  105,   80,   64,   66,   67,
		/*   350 */   157,  164,    4,  103,  104,   65,  109,  118,  234,  114,
		/*   360 */   107,   24,  159,   65,  105,   87,   64,   66,   67,   65,
		/*   370 */    19,   23,   88,   80,   64,   66,   67,   65,  114,   47,
		/*   380 */    64,   66,   67,  165,   65,  148,  148,   78,   64,   66,
		/*   390 */    67,   84,  133,   65,  140,   64,   66,   67,   13,  154,
		/*   400 */   150,   65,  100,   33,   64,   66,   67,   65,   14,  160,
		/*   410 */    97,   82,   64,   66,   67,   65,   93,   53,   64,   66,
		/*   420 */    67,  132,   92,   65,   17,   45,   64,   66,   67,   65,
		/*   430 */   161,  163,  168,   35,   64,   66,   67,   65,  168,   62,
		/*   440 */    64,   66,   67,  168,   65,  168,  168,   55,   64,   66,
		/*   450 */    67,  168,  168,   65,   98,   64,   66,   67,  168,  168,
		/*   460 */   168,   65,  168,   37,   64,   66,   67,   65,  168,  168,
		/*   470 */   168,  124,   64,   66,   67,  168,  168,   28,   64,   66,
		/*   480 */    67,    3,    5,   65,  168,  101,  102,  168,   65,  168,
		/*   490 */   168,  168,  168,   39,   64,   66,   67,   65,   51,   64,
		/*   500 */    66,   67,   65,  168,  168,  106,  168,  111,   64,   66,
		/*   510 */    67,  168,   60,   64,   66,   67,   65,  168,  168,   15,
		/*   520 */    58,   65,   26,  168,  168,   65,   41,   64,   66,   67,
		/*   530 */   168,   73,   64,   66,   67,   49,   64,   66,   67,   65,
		/*   540 */     3,    5,  168,   65,  101,  102,  168,  168,  168,  116,
		/*   550 */    64,   66,   67,   43,   64,   66,   67,  168,   38,   40,
		/*   560 */    42,  168,   56,  168,  168,  143,
	);

	private $yy_lookahead = array(
		/*     0 */     2,    3,   18,    5,    6,    7,    8,    9,   10,   11,
		/*    10 */    12,   13,   14,   15,   16,   29,   18,    2,    3,    0,
		/*    20 */     5,    6,    7,    8,    9,   10,   18,   12,   13,   14,
		/*    30 */    15,   16,   25,   18,   21,   37,   28,   30,    2,    3,
		/*    40 */    52,    5,    6,    7,    8,    9,   10,   32,   12,   13,
		/*    50 */    14,   15,   16,   42,   18,   26,   27,    2,    3,   18,
		/*    60 */     5,    6,    7,    8,    9,   10,   30,   12,   13,   14,
		/*    70 */    15,   16,   68,   18,   65,   66,    2,    3,   61,    5,
		/*    80 */     6,    7,    8,    9,   10,   30,   12,   13,   14,   15,
		/*    90 */    16,   31,   18,   26,    5,    6,    7,    8,    9,   10,
		/*   100 */    33,   12,   13,   14,   15,   16,   32,   18,   25,    2,
		/*   110 */     3,   64,    5,    6,    7,    8,    9,   10,   35,   12,
		/*   120 */    13,   14,   15,   16,   25,   18,   29,   61,    2,    3,
		/*   130 */    61,    5,    6,    7,    8,    9,   10,   30,   12,   13,
		/*   140 */    14,   15,   16,   26,   18,   79,   26,    2,    3,   62,
		/*   150 */     5,    6,    7,    8,    9,   10,   30,   12,   13,   14,
		/*   160 */    15,   16,   30,   18,   30,   30,    2,    3,   29,    5,
		/*   170 */     6,    7,    8,    9,   10,   30,   12,   13,   14,   15,
		/*   180 */    16,    4,   18,    2,    3,    1,    5,    6,    7,    8,
		/*   190 */     9,   10,   17,   12,   13,   14,   15,   16,   25,   18,
		/*   200 */    25,   37,   65,   66,   29,   68,   31,   59,   29,   28,
		/*   210 */    35,   36,    2,    3,   30,    5,    6,    7,    8,    9,
		/*   220 */    10,   46,   12,   13,   14,   15,   16,    3,   18,    5,
		/*   230 */     6,    7,    8,    9,   10,   52,   12,   13,   14,   15,
		/*   240 */    16,   27,   18,   25,    7,    8,    9,   10,   33,   12,
		/*   250 */    13,   14,   15,   16,   29,   18,   38,   39,   40,   41,
		/*   260 */    52,   43,   44,   45,   46,   47,   19,   20,   21,   22,
		/*   270 */    23,   24,   19,   20,   21,   22,   23,   24,   59,   62,
		/*   280 */    30,   34,   20,   21,   22,   23,   24,   34,   69,   70,
		/*   290 */    71,   72,   59,   53,   54,   48,   34,   57,   58,   21,
		/*   300 */     1,   48,   69,   70,   71,   72,   26,   74,   75,   76,
		/*   310 */    48,    0,   29,   29,   21,   22,   23,   24,   12,   13,
		/*   320 */    14,   15,   16,   26,   18,   55,   56,   34,   31,   59,
		/*   330 */    60,   32,    1,   22,   23,   24,   59,   50,   51,   52,
		/*   340 */    64,   48,   72,   62,   67,   34,   69,   70,   71,   72,
		/*   350 */    80,   21,   22,   23,   24,   59,   19,   20,   21,   48,
		/*   360 */    78,   30,   29,   59,   34,   69,   70,   71,   72,   59,
		/*   370 */    29,   67,   76,   69,   70,   71,   72,   59,   48,   69,
		/*   380 */    70,   71,   72,   61,   59,   59,   59,   69,   70,   71,
		/*   390 */    72,   32,    1,   59,   69,   70,   71,   72,   63,   73,
		/*   400 */    73,   59,   52,   69,   70,   71,   72,   59,   64,   26,
		/*   410 */    29,   69,   70,   71,   72,   59,   64,   69,   70,   71,
		/*   420 */    72,   30,   26,   59,   66,   69,   70,   71,   72,   59,
		/*   430 */    81,   52,   82,   69,   70,   71,   72,   59,   82,   69,
		/*   440 */    70,   71,   72,   82,   59,   82,   82,   69,   70,   71,
		/*   450 */    72,   82,   82,   59,   69,   70,   71,   72,   82,   82,
		/*   460 */    82,   59,   82,   69,   70,   71,   72,   59,   82,   82,
		/*   470 */    82,   69,   70,   71,   72,   82,   82,   69,   70,   71,
		/*   480 */    72,   53,   54,   59,   82,   57,   58,   82,   59,   82,
		/*   490 */    82,   82,   82,   69,   70,   71,   72,   59,   69,   70,
		/*   500 */    71,   72,   59,   82,   82,   77,   82,   69,   70,   71,
		/*   510 */    72,   82,   69,   70,   71,   72,   59,   82,   82,   65,
		/*   520 */    66,   59,   68,   82,   82,   59,   69,   70,   71,   72,
		/*   530 */    82,   69,   70,   71,   72,   69,   70,   71,   72,   59,
		/*   540 */    53,   54,   82,   59,   57,   58,   82,   82,   82,   69,
		/*   550 */    70,   71,   72,   69,   70,   71,   72,   82,   14,   15,
		/*   560 */    16,   82,   18,   82,   82,   78,
	);

	const YY_SHIFT_USE_DFLT = -17;

	private $yy_shift_ofst = array(
		/*     0 */   -17,   19,  311,  -17,  -17,  218,  -17,  -17,  -17,  -17,
		/*    10 */   215,   29,  -17,  -17,  297,  -16,  117,  -17,  341,  175,
		/*    20 */    67,  280,  -17,  331,  -17,   60,  -17,  175,   15,  -17,
		/*    30 */   175,  224,  175,   89,  175,  544,  175,  544,  175,   41,
		/*    40 */   175,   41,  175,   41,  175,  237,  175,  237,  175,  306,
		/*    50 */   175,  306,  175,  306,  175,  306,  117,  -16,  -17,  175,
		/*    60 */    41,  175,   36,  -17,  -17,  -17,  -17,  -17,  -17,  -17,
		/*    70 */   175,   -2,  175,   74,  284,  175,  184,  175,  210,  -17,
		/*    80 */   210,  175,  210,  359,  -17,  299,  175,  164,  -17,  -17,
		/*    90 */    60,  396,  -17,  297,    8,  -17,  381,  175,  107,  -17,
		/*   100 */   247,  -17,  -17,  -17,  -17,  -17,  337,  278,  -17,  283,
		/*   110 */   175,   55,  -17,  253,  214,  175,  181,  -17,  -17,  293,
		/*   120 */   179,  173,  177,  175,  145,  -17,  139,   99,   67,  120,
		/*   130 */   -17,  391,  -17,   99,  -17,  -17,   97,   99,   11,  175,
		/*   140 */   126,  -17,  262,   13,  -17,  -17,  -14,   83,  132,  134,
		/*   150 */   135,  -17,  225,   83,  250,  -17,  -17,  -17,  333,  383,
		/*   160 */   -17,    7,  -17,  330,  -17,  -17,
	);

	const YY_REDUCE_USE_DFLT = -13;

	private $yy_reduce_ofst = array(
		/*     0 */   287,  -13,  240,  -13,  -13,  270,  -13,  -13,  -13,  -13,
		/*    10 */   217,  -13,  335,  344,  454,  -13,  358,  -13,  276,  304,
		/*    20 */   281,  -13,  -13,  -13,   47,    4,  -13,  408,  -13,  -13,
		/*    30 */   219,  -13,  334,  -13,  364,  -13,  394,  -13,  424,  -13,
		/*    40 */   457,  -13,  484,  -13,  356,  -13,  310,  -13,  466,  -13,
		/*    50 */   429,  -13,  348,  -13,  378,  -13,    9,  -13,  -13,  443,
		/*    60 */   -13,  370,  -13,  -13,  -13,  -13,  -13,  -13,  -13,  -13,
		/*    70 */   233,  -13,  462,  -13,  -13,  277,  -13,  318,  -13,  -13,
		/*    80 */   -13,  342,  -13,  -13,  -13,  -13,  296,  -13,  -13,  -13,
		/*    90 */     4,  -13,  352,  137,  -13,  -13,  -13,  385,  -13,  350,
		/*   100 */   428,  -13,  -13,  -13,  -13,  -13,  282,  -13,  -13,  -13,
		/*   110 */   438,  -13,  208,  240,  -13,  480,  -13,  -13,  183,  240,
		/*   120 */   -13,  148,  -13,  402,  -13,  -13,  -13,   66,   87,  -13,
		/*   130 */   -13,  -13,  -13,   69,  -13,  -13,  -13,   17,  -13,  325,
		/*   140 */   -13,  -12,  487,  -13,  -13,  -13,  -13,  327,  -13,  -13,
		/*   150 */   -13,  -13,  -13,  326,  -13,  -13,  -13,  -13,  -13,  -13,
		/*   160 */   349,  322,  379,  240,  -13,  -13,
	);

	private $yy_default = array(
		/*     0 */   169,  250,  197,  168,  170,  250,  171,  172,  177,  178,
		/*    10 */   194,  250,  180,  189,  185,  181,  250,  183,  189,  193,
		/*    20 */   250,  250,  195,  250,  189,  186,  188,  250,  250,  190,
		/*    30 */   250,  198,  250,  199,  250,  200,  250,  201,  250,  202,
		/*    40 */   250,  203,  250,  204,  250,  206,  250,  207,  250,  208,
		/*    50 */   250,  209,  250,  210,  250,  211,  185,  217,  184,  250,
		/*    60 */   205,  250,  250,  212,  213,  214,  215,  216,  218,  219,
		/*    70 */   227,  228,  250,  250,  250,  193,  250,  250,  191,  244,
		/*    80 */   192,  250,  229,  250,  222,  250,  250,  228,  225,  226,
		/*    90 */   187,  250,  189,  185,  250,  182,  250,  250,  250,  169,
		/*   100 */   197,  173,  174,  175,  176,  196,  250,  250,  230,  250,
		/*   110 */   250,  250,  169,  197,  250,  250,  250,  249,  169,  197,
		/*   120 */   250,  250,  250,  250,  250,  235,  250,  250,  250,  250,
		/*   130 */   179,  250,  236,  250,  237,  238,  250,  250,  250,  250,
		/*   140 */   250,  169,  197,  250,  239,  240,  250,  250,  250,  250,
		/*   150 */   250,  241,  250,  250,  250,  242,  243,  245,  250,  250,
		/*   160 */   248,  250,  169,  197,  246,  247,
	);

	
	/* The next table maps tokens into fallback tokens.  If a construct
	** like the following:
	** 
	**      %fallback ID X Y Z.
	**
	** appears in the grammer, then ID becomes a fallback token for X, Y,
	** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser
	** but it does not parse, the type of the token is changed to ID and
	** the parse is retried before an error is thrown.
	*/
	private $yyFallback = array(
		#INCLUDE GENERATED
		#END
	);
	
	function __construct() {
		$this->stack = new Parser_Stack();		
		$this->yyerrcnt = -1;
	}
	
	/* The following function deletes the value associated with a
	** symbol.  The symbol can be either a terminal or nonterminal.
	** "yymajor" is the symbol code, and "yypminor" is a pointer to
	** the value.
	*/
	private function yy_destructor($yymajor, $yypminor) {
		switch ($yymajor) {
			/* Here is inserted the actions which take place when a
			** terminal or non-terminal is destroyed.  This can happen
			** when the symbol is popped from the stack during a
			** reduce or during error processing or when a parser is 
			** being destroyed before it is finished parsing.
			**
			** Note: during a reduce, the only symbols destroyed are those
			** which appear on the RHS of the rule, but which are not used
			** inside the C code.
			*/
			#INCLUDE GENERATED
			default:  break;   /* If no destructor action specified: do nothing */
			#END
		}
	}
	
	/**
	 * Pop the parser's stack once.
	 *
	 * If there is a destructor routine associated with the token which
	 * is popped from the stack, then call it.
	 *
	 * @return int The major token number for the symbol popped.
	 */
	private function yy_pop_parser_stack() {
		$yytos = $this->stack->getTop();
		
		// if no items on the stack
		if (! $this->stack->size()) return 0;
		
		if (defined('DEBUG')) {
			echo "Popping " . $this->getSymbolName($yytos->major) . "\n";
		}
		
		$yymajor = $yytos->major;
		$this->yy_destructor($yymajor, $yytos->minor);
		
		$this->stack->pop();
		
		return $yymajor;
	}
	
	/**
	 * Find the appropriate action for a parser given the terminal
	 * look-ahead token iLookAhead.
	 *
	 * If the look-ahead token is YYNOCODE, then check to see if the action is
	 * independent of the look-ahead.  If it is, return the action, otherwise
	 * return YY_NO_ACTION.
	 *
	 * @param int $iLookAhead Look-ahead token
	 * @return int Number of the action to perform
	 */
	private function yy_find_shift_action($iLookAhead) {
		$stateno = $this->stack->getTop()->stateno;
		
		/* if (! $this->stack->size()) return YY_NO_ACTION;  */
		$i = $this->yy_shift_ofst[$stateno];
	  
		if ($i == self::YY_SHIFT_USE_DFLT)
			return $this->yy_default[$stateno];
	  
		if ($iLookAhead == self::YYNOCODE)
			return self::YY_NO_ACTION;
			
		$i += $iLookAhead;
		
		if ($i < 0 || $i >= count($this->yy_action) || $this->yy_lookahead[$i] != $iLookAhead) {
			if (self::YYFALLBACK) {
				// int iFallback;            /* Fallback token */
				
				if ($iLookAhead < count($this->yyFallback)
					&& ($iFallback = $this->yyFallback[$iLookAhead]) != 0) {
						
					if (defined('DEBUG')) {
						printf("FALLBACK %s => %s\n"
							,$this->getSymbolName($iLookAhead)
							,$this->getSymbolName($iFallback));
					
					}
					
					return $this->yy_find_shift_action($iFallback);
				}
			}
				
			return $this->yy_default[$stateno];
		} else {
			return $this->yy_action[$i];
		}
	}
	
	/**
	 * Find reduce action
	 *
	 * Find the appropriate action for a parser given the non-terminal
	 * look-ahead token iLookAhead.
	 *
	 * If the look-ahead token is YYNOCODE, then check to see if the action is
	 * independent of the look-ahead.  If it is, return the action, otherwise
	 * return YY_NO_ACTION.
	 *
	 * @param int $stateno Current state number 
	 * @return int The look-ahead token
	 */
	private function yy_find_reduce_action($stateno, $iLookAhead) {
		
		$i = $this->yy_reduce_ofst[$stateno];
		if ($i == self::YY_REDUCE_USE_DFLT)
			return $this->yy_default[$stateno];
		
		if ($iLookAhead == self::YYNOCODE)
			return self::YY_NO_ACTION;
		
		
		$i += $iLookAhead;
		
		if ($i < 0 || $i >= count($this->yy_action) || $this->yy_lookahead[$i] != $iLookAhead) {
			return $this->yy_default[$stateno];
		} else {
			return $this->yy_action[$i];
		}	
	}
	
	/**
	 * Perform a shift action.
	 *
	 * @param int $yyNewState The new state to shift in
	 * @param int $yyMajor The major token to shift in
	 * @param $yypMinor Pointer t0 the minor token to shift in
	 */
	private function yy_shift($yyNewState, $yyMajor, $yypMinor) {
				
		if ($this->stack->size() + 1 >= self::YYSTACKDEPTH) {
			if (defined('DEBUG')) {
				printf("Stack Overflow!\n");
			}
			
			while ($this->stack->size()) $this->yy_pop_parser_stack();
			
			// Here code is inserted which will execute if the parser
			// stack every overflows
			return;
		}
		
		$yytos = new Parser_StackEntry();
		$yytos->stateno = $yyNewState;
		$yytos->major = $yyMajor;
		$yytos->minor = $yypMinor;
		$this->stack->push($yytos);
		
		if (defined('DEBUG')) {
			printf("Shift %d\n", $yyNewState);
			printf("Stack:");
			
			$stack = $this->stack->getArray();
			for ($i = 1; $i < count($stack); $i++)
				printf(" %s", $this->getSymbolName($stack[$i]->major));
				
	    	printf("\n");
	    }
	}
	
	/**
	 * Reduce action
	 *
	 * Perform a reduce action and the shift that must immediately
	 * follow the reduce.
	 *
	 * @param int $yyruleno Number ot hte rule by which to reduce
	 */
	private function yy_reduce($yyruleno) {
		
		$yygotominor = new Parser_Minor();         /* The LHS of the rule reduced */
		
		$stack = $this->stack;
		
		if (defined('DEBUG')) {
			printf("Reduce [%s].\n", $this->getRuleName($yyruleno));
		}
		
		switch ($yyruleno) {
			/* Beginning here are the reduction cases.  A typical example
			** follows:
			**   case 0:
			**  #line <lineno> <grammarfile>
			**     { ... }           // User supplied code
			**  #line <lineno> <thisfile>
			**     break;
			*/
			case 0:
#line 118 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ 
	$this->ast = $stack->getRelative(0)->minor->yy0;
}
#line 722 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 1:
			case 7:
			case 8:
			case 11:
			case 12:
			case 47:
			case 48:
			case 49:
			case 50:
			case 54:
			case 57:
			case 77:
			case 79:
#line 122 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = $stack->getRelative(0)->minor->yy0; }
#line 739 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 2:
#line 124 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = $stack->getRelative(-1)->minor->yy0; $yygotominor->yy0->addNode($stack->getRelative(0)->minor->yy0); }
#line 744 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 3:
#line 125 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTBlock(); }
#line 749 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 4:
#line 127 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTSmurk($stack->getRelative(0)->minor->yy0->value); }
#line 754 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 5:
			case 6:
#line 128 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = $stack->getRelative(0)->minor->yy0; $yygotominor->yy0->escapes = $stack->getRelative(-1)->minor->yy0; }
#line 760 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 9:
#line 134 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTMultiLineComment($stack->getRelative(0)->minor->yy0->value); }
#line 765 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 10:
#line 135 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTSingleLineComment($stack->getRelative(0)->minor->yy0->value); }
#line 770 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 13:
#line 142 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{
	// calculate smurk offset
	$start = $stack->getRelative(-2)->minor->yy0->offset;
	$length = ($stack->getRelative(0)->minor->yy0->offset + strlen($stack->getRelative(0)->minor->yy0->value)) - $start;
	
	$yygotominor->yy0 = new ASTReference();
	$yygotominor->yy0->name = $stack->getRelative(0)->minor->yy0->value;
	$yygotominor->yy0->silent = $stack->getRelative(-1)->minor->yy0;
	$yygotominor->yy0->modifiers = array(); // no modifiers
	$yygotominor->yy0->smurk = $this->compileEngine->getInputSubstring($start, $length);
}
#line 785 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 14:
#line 0 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $this->referenceOffset = $stack->getRelative(0)->minor->yy0->offset + strlen($stack->getRelative(0)->minor->yy0->value); }
#line 790 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 15:
#line 155 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ 
	$start = $stack->getRelative(-5)->minor->yy0->offset;
	$length = $this->referenceOffset - $start;
	
	$yygotominor->yy0 = new ASTReference();
	$yygotominor->yy0->name = $stack->getRelative(-3)->minor->yy0->value;
	$yygotominor->yy0->silent = $stack->getRelative(-4)->minor->yy0;
	$yygotominor->yy0->modifiers = $stack->getRelative(0)->minor->yy0;
	$yygotominor->yy0->smurk = $this->compileEngine->getInputSubstring($start, $length);
	$yygotominor->yy0->indexes = $stack->getRelative(-1)->minor->yy0;
}
#line 805 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 16:
#line 168 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ 	
	// calculate smurk offset
	$start = $stack->getRelative(-6)->minor->yy0->offset;
	$length = ($stack->getRelative(0)->minor->yy0->offset + 1) - $start;
	
	$yygotominor->yy0 = new ASTReference();
	$yygotominor->yy0->name = $stack->getRelative(-3)->minor->yy0->value;
	$yygotominor->yy0->silent = $stack->getRelative(-5)->minor->yy0;
	$yygotominor->yy0->modifiers = $stack->getRelative(-1)->minor->yy0;
	$yygotominor->yy0->smurk = $this->compileEngine->getInputSubstring($start, $length);
	$yygotominor->yy0->indexes = $stack->getRelative(-2)->minor->yy0;
	$yygotominor->yy0->braced = true;
}
#line 822 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 17:
			case 25:
			case 59:
			case 71:
#line 182 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $stack->getRelative(-2)->minor->yy0[] = $stack->getRelative(0)->minor->yy0; $yygotominor->yy0 = $stack->getRelative(-2)->minor->yy0; }
#line 830 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 18:
			case 26:
			case 60:
			case 72:
#line 183 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = array($stack->getRelative(0)->minor->yy0); }
#line 838 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 19:
			case 23:
			case 27:
			case 61:
			case 82:
#line 184 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = array(); }
#line 847 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 20:
#line 188 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{
	$this->referenceOffset = $stack->getRelative(-1)->minor->yy0->offset + 1;
	
	$yygotominor->yy0 = new ASTModifier(); 
	$yygotominor->yy0->name = $stack->getRelative(-4)->minor->yy0->value;
	$yygotominor->yy0->parameters = $stack->getRelative(-2)->minor->yy0;
	$yygotominor->yy0->parenthesis = true;
	$yygotominor->yy0->index = $stack->getRelative(0)->minor->yy0;
	$yygotominor->yy0->line = $stack->getRelative(-4)->minor->yy0->line;
}
#line 861 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 21:
#line 201 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{
	$this->referenceOffset = $stack->getRelative(-1)->minor->yy0->offset + strlen($stack->getRelative(-1)->minor->yy0->value);
	
	$yygotominor->yy0 = new ASTModifier();
	$yygotominor->yy0->name = $stack->getRelative(-1)->minor->yy0->value;
	$yygotominor->yy0->index = $stack->getRelative(0)->minor->yy0;
	$yygotominor->yy0->line = $stack->getRelative(-1)->minor->yy0->line;
}
#line 873 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 22:
			case 81:
#line 211 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $stack->getRelative(-1)->minor->yy0[] = $stack->getRelative(0)->minor->yy0; $yygotominor->yy0 = $stack->getRelative(-1)->minor->yy0; }
#line 879 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 24:
#line 214 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ 
	$this->referenceOffset = $stack->getRelative(0)->minor->yy0->offset + 1;
	$yygotominor->yy0 = $stack->getRelative(-1)->minor->yy0; 
}
#line 887 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 28:
#line 224 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = false; }
#line 892 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 29:
#line 225 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = true; }
#line 897 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 30:
#line 228 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = strlen($stack->getRelative(0)->minor->yy0->value); }
#line 902 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 31:
#line 229 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = 0; }
#line 907 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 32:
#line 232 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTLogicalOr($stack->getRelative(-2)->minor->yy0, $stack->getRelative(0)->minor->yy0); }
#line 912 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 33:
#line 233 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTLogicalAnd($stack->getRelative(-2)->minor->yy0, $stack->getRelative(0)->minor->yy0); }
#line 917 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 34:
#line 234 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTAdd($stack->getRelative(-2)->minor->yy0, $stack->getRelative(0)->minor->yy0); }
#line 922 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 35:
#line 235 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTSub($stack->getRelative(-2)->minor->yy0, $stack->getRelative(0)->minor->yy0); }
#line 927 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 36:
#line 236 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTMultiply($stack->getRelative(-2)->minor->yy0, $stack->getRelative(0)->minor->yy0); }
#line 932 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 37:
#line 237 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTDivide($stack->getRelative(-2)->minor->yy0, $stack->getRelative(0)->minor->yy0); }
#line 937 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 38:
#line 238 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTModulus($stack->getRelative(-2)->minor->yy0, $stack->getRelative(0)->minor->yy0); }
#line 942 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 39:
#line 239 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTNot($stack->getRelative(0)->minor->yy0); }
#line 947 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 40:
#line 240 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTEqual($stack->getRelative(-2)->minor->yy0, $stack->getRelative(0)->minor->yy0); }
#line 952 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 41:
#line 241 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTNotEqual($stack->getRelative(-2)->minor->yy0, $stack->getRelative(0)->minor->yy0); }
#line 957 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 42:
#line 242 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTGreaterThan($stack->getRelative(-2)->minor->yy0, $stack->getRelative(0)->minor->yy0); }
#line 962 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 43:
#line 243 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTLessThan($stack->getRelative(-2)->minor->yy0, $stack->getRelative(0)->minor->yy0); }
#line 967 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 44:
#line 244 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTGreaterOrEqual($stack->getRelative(-2)->minor->yy0, $stack->getRelative(0)->minor->yy0); }
#line 972 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 45:
#line 245 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTLessOrEqual($stack->getRelative(-2)->minor->yy0, $stack->getRelative(0)->minor->yy0); }
#line 977 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 46:
#line 246 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTParenthesis($stack->getRelative(-1)->minor->yy0); }
#line 982 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 51:
#line 251 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTScalarObject($stack->getRelative(-2)->minor->yy0, $stack->getRelative(0)->minor->yy0); }
#line 987 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 52:
			case 55:
#line 254 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTLiteral($stack->getRelative(0)->minor->yy0->value); }
#line 993 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 53:
#line 255 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTNumber($stack->getRelative(0)->minor->yy0->value); }
#line 998 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 56:
#line 262 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{
	$yygotominor->yy0 = new ASTArray();
	$yygotominor->yy0->elements = $stack->getRelative(-1)->minor->yy0;
}
#line 1006 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 58:
#line 269 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{
	$yygotominor->yy0 = new ASTArrayRange();
	$yygotominor->yy0->low = $stack->getRelative(-2)->minor->yy0;
	$yygotominor->yy0->high = $stack->getRelative(0)->minor->yy0;
}
#line 1015 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 62:
#line 279 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = array(null, $stack->getRelative(0)->minor->yy0); }
#line 1020 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 63:
#line 280 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = array($stack->getRelative(-2)->minor->yy0, $stack->getRelative(0)->minor->yy0); }
#line 1025 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 64:
#line 284 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{	
	$yygotominor->yy0 = new ASTIfDirective($stack->getRelative(-5)->minor->yy0, $stack->getRelative(-3)->minor->yy0, null); 
	
	if ($stack->getRelative(-2)->minor->yy0 !== null) {
		$yygotominor->yy0->setFalseBlock($stack->getRelative(-2)->minor->yy0);
		$stack->getRelative(-2)->minor->yy0->setFalseBlock($stack->getRelative(-1)->minor->yy0);
		$last = $stack->getRelative(-2)->minor->yy0;
	} else {
		$yygotominor->yy0->setFalseBlock($stack->getRelative(-1)->minor->yy0);
	}
}
#line 1040 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 65:
#line 297 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{
	$yygotominor->yy0 = new ASTElseIfDirective($stack->getRelative(-2)->minor->yy0, $stack->getRelative(0)->minor->yy0, null);
	$yygotominor->yy0->setFalseBlock($stack->getRelative(-5)->minor->yy0);
}
#line 1048 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 66:
			case 68:
#line 302 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = null; }
#line 1054 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 67:
#line 304 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTElseDirective($stack->getRelative(0)->minor->yy0); }
#line 1059 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 69:
#line 310 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ 
	$yygotominor->yy0 = new ASTSetDirective($stack->getRelative(-3)->minor->yy0, $stack->getRelative(-1)->minor->yy0); 
}
#line 1066 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 70:
#line 316 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{
	$yygotominor->yy0 = new ASTLocalDirective($stack->getRelative(-1)->minor->yy0);
}
#line 1073 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 73:
#line 326 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ 
	$yygotominor->yy0 = new ASTForeachDirective($stack->getRelative(-4)->minor->yy0, $stack->getRelative(-6)->minor->yy0, $stack->getRelative(-2)->minor->yy0, $stack->getRelative(-1)->minor->yy0, $stack->getRelative(-8)->minor->yy0->line); 
}
#line 1080 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 74:
#line 331 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ $yygotominor->yy0 = new ASTStopDirective(); }
#line 1085 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 75:
#line 334 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{
	$yygotominor->yy0 = new ASTIncludeDirective();
	$yygotominor->yy0->resource = $stack->getRelative(-1)->minor->yy0;
	$yygotominor->yy0->line = $stack->getRelative(-3)->minor->yy0->line;
}
#line 1094 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 76:
#line 341 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{ 
	$yygotominor->yy0 = new ASTParseDirective();
	$yygotominor->yy0->resource = $stack->getRelative(-1)->minor->yy0;
	$yygotominor->yy0->line = $stack->getRelative(-3)->minor->yy0->line;
}
#line 1103 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 78:
#line 351 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{
	$start = $stack->getRelative(-3)->minor->yy0->offset;
	$length = ($stack->getRelative(0)->minor->yy0->offset + 1) - $start;
	
	$yygotominor->yy0 = new ASTMacroCall();
	$yygotominor->yy0->parameters = $stack->getRelative(-1)->minor->yy0;
	$yygotominor->yy0->name = $stack->getRelative(-3)->minor->yy0->value;
	$yygotominor->yy0->smurk = $this->compileEngine->getInputSubstring($start, $length);
}
#line 1116 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 80:
#line 364 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{
	$yygotominor->yy0 = new ASTMacro();
	$yygotominor->yy0->name = $stack->getRelative(-4)->minor->yy0->value;
	$yygotominor->yy0->parameters = $stack->getRelative(-3)->minor->yy0;
	$yygotominor->yy0->block = $stack->getRelative(-1)->minor->yy0;
}
#line 1126 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
			case 83:
#line 375 "GeryEngine\\lib\\compiler\\Parser\\parser.y"
{
	$yygotominor->yy0 = new ASTInterpolation();
	$yygotominor->yy0->expression = $stack->getRelative(-1)->minor->yy0;
}
#line 1134 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
				break;
		}
		
		$rule = $this->yyRuleInfo[$yyruleno];
		$yygoto = $rule[0];
		$yysize = $rule[1];
		
		// find next action
		$yyact = $this->yy_find_reduce_action($stack->getRelative(-$yysize)->stateno, $yygoto);
		
		$this->stack->pop($yysize);
		
		if ($yyact < self::YYNSTATE) {
			if (! defined('DEBUG')) {
				/* If we are not debugging and the reduce action popped at least
				** one element off the stack, then we can push the new element back
				** onto the stack here, and skip the stack overflow test in yy_shift().
				** That gives a significant speed improvement. */
				
				if ($yysize) {
					$yymsp = new Parser_StackEntry();
					$yymsp->stateno = $yyact;
					$yymsp->major = $yygoto;
					$yymsp->minor = $yygotominor;
					$this->stack->push($yymsp);
					
				} else {
					$this->yy_shift($yyact, $yygoto, $yygotominor);
				}
			} else {
				$this->yy_shift($yyact, $yygoto, $yygotominor);
			}
		} else if($yyact == self::YY_ACCEPT_ACTION) {
			$this->yy_accept();
		}
	}
	
	/**
	 * The following code executes when the parse fails
	 */
	private function yy_parse_failed() {
		
		if (defined('DEBUG')) {
			printf("Fail!\n");
		}
		
		while ($this->stack->size()) $this->yy_pop_parser_stack();
		
		// Here code is inserted which will be executed whenever the
		// parser fails
		
	}
	
	/**
	 * The following code executes when a syntax error first occurs.
	 *
	 * @param int $yymajor The major type of the error token
	 * @param $yyminor The minor type of the error token
	 */
	private function yy_syntax_error($yymajor, $yyminor) {
#line 57 "GeryEngine\\lib\\compiler\\Parser\\parser.y"

	
	if ($yymajor) {
	
		$singleTokens = array(
			TK_DOLLAR => '$'
			,TK_DOTDOT => '..'
			,TK_PLUS => '+'
			,TK_MIN => '-'
			,TK_STAR => '*'
			,TK_SLASH => '/'
			,TK_PERCENT => '%'
			,TK_DOT => '.'
			,TK_NOT => '!'
			,TK_IS => '='
			,TK_AND => 'AND'
		);
		
		if ($yymajor == TK_SMURK) {
			$value = $yyminor->yy0->value;
			if ($value > 20) {
				$value = substr($value, 0, 20) . '...';
			}
				
			$tokenName = 'TK_SMURK with value [' . $value . ']';
		} else {
			$tokenName = $this->getSymbolName($yymajor);
		}
		
		$tokenDescr = (key_exists($yymajor, $singleTokens)) 
			? $singleTokens[$yymajor]
			: $tokenName . '(' . $yyminor->yy0->value .')';
		
		$msg = sprintf("Unexpected '%s' on line %d character %d"
			,$tokenDescr
			,$this->compileEngine->getLine()
			,$this->compileEngine->getLexer()->getCharacter()
		);
		
	
	} else {
		$msg = "Unexpected end of file";
	}
	
	// get expected tokens
	$expected = $this->getExpectedTokens();
	
	// build msg
	$msg .= "\n";
	$msg .= "Was expecting one of:";
	foreach ($expected as $token) {
		$msg .= "\n\t" . $token;
	}
	
	// throw the exception
	throw new GeryParseErrorException($msg);
#line 1253 "GeryEngine\\lib\\compiler\\Parser\\parser.php"
	}
	
	/**
	 * The following is executed when the parser accepts
	 */
	private function yy_accept() {
		if (defined('DEBUG')) {
			printf("Accept!\n");
	  	}
	  	
	  	while ($this->stack->size()) $this->yy_pop_parser_stack();
	  	
	  	// Here code is inserted which will be executed whenever the
	  	// parser accepts
	}
	
	
	/**
	 * The main parser program.
	 *
	 * The first argument is a pointer to a structure obtained from
	 * "ParserAlloc" which describes the current state of the parser.
	 * The second argument is the major token number.  The third is
	 * the minor token.  The fourth optional argument is whatever the
	 * user wants (and specified in the grammar) and is available for
	 * use by the action routines.
	 *
	 * @param int $yymajor The major token number.
	 * @param $yyminor The minor token number.
	 */
	public function parse($yymajor, $yyminor) {

		$yyminorunion = new Parser_Minor();
		$yyerrorhit = false; // true if yymajor has invoked an error
		
		// (re)initialize the parser, if necessary
		if (! $this->stack->size()) {
			
			if ($yymajor == 0) return;
			
			$this->yyerrcnt = -1;
			$this->stack->push(new Parser_StackEntry());
		}
		
		$yyminorunion->yy0 = $yyminor;
		$yyendofinput = ($yymajor == 0);
		
		if (defined('DEBUG')) {
			printf("Input %s\n", $this->getSymbolName($yymajor));
		}
	
		do {
			$yyact = $this->yy_find_shift_action($yymajor);
			if ($yyact < self::YYNSTATE) {
				$this->yy_shift($yyact, $yymajor, $yyminorunion);
				$this->yyerrcnt--;
				
				if ($yyendofinput && $this->stack->size()) {
					$yymajor = 0;
				} else {
					$yymajor = self::YYNOCODE;
				}
				
			} else if ($yyact < self::YY_ERROR_ACTION) {
				$this->yy_reduce($yyact - self::YYNSTATE);
				
			} else if($yyact == self::YY_ERROR_ACTION) {
				
				if (defined('DEBUG')) {
					printf("Syntax Error!\n");
				}
				
				if (defined(self::YYERRORSYMBOL)) {
					/* A syntax error has occurred.
					** The response to an error depends upon whether or not the
					** grammar defines an error token "ERROR".  
					**
					** This is what we do if the grammar does define ERROR:
					**
					**  * Call the %syntax_error function.
					**
					**  * Begin popping the stack until we enter a state where
					**    it is legal to shift the error symbol, then shift
					**    the error symbol.
					**
					**  * Set the error count to three.
					**
					**  * Begin accepting and shifting new tokens.  No new error
					**    processing will occur until three tokens have been
					**    shifted successfully.
					**
					*/
					
					if ($this->yyerrcnt < 0) {
						$this->yy_syntax_error($yymajor, $yyminorunion);
					}
					
					$yymx = $this->stack->getTop()->major;
					
					if ($yymx == self::YYERRORSYMBOL || $yyerrorhit) {
						if (defined('DEBUG')) {
							printf("Discard input token %s\n", $this->getSymbolName($yymajor));
						}
						
						$this->yy_destructor($yymajor, $yyminorunion);
						$yymajor = self::YYNOCODE;
					} else {
						
						while(
							$this->stack->size()
							&& $yymx != self::YYERRORSYMBOL 
							&& ($yyact = $this->yy_find_shift_action(self::YYERRORSYMBOL)) >= self::YYNSTATE
						) {
							$this->yy_pop_parser_stack();
						}
						
						if (! $this->stack->size() || $yymajor == 0) {
							$this->yy_destructor($yymajor, $yyminorunion);
							$this->yy_parse_failed();
							$yymajor = self::YYNOCODE;
							
						} else if ($yymx != self::YYERRORSYMBOL) {
							
							$u2 = new Parser_Minor();
							$attr = self::YYERRSYMDT;
							$u2->$attr = 0;
							
							$this->yy_shift($yyact, self::YYERRORSYMBOL, $u2);
						}
					}
					
					$this->yyerrcnt = 3;
					$yyerrorhit = true;
					
				} else {  /* YYERRORSYMBOL is not defined */
				
					/* This is what we do if the grammar does not define ERROR:
					**
					**  * Report an error message, and throw away the input token.
					**
					**  * If the input token is $, then fail the parse.
					**
					** As before, subsequent error messages are suppressed until
					** three input tokens have been successfully shifted.
					*/
					
					if ($this->yyerrcnt <= 0) {
						$this->yy_syntax_error($yymajor, $yyminorunion);
					}
					
					$this->yyerrcnt = 3;
					$this->yy_destructor($yymajor, $yyminorunion);
					
					if ($yyendofinput) {
						$this->yy_parse_failed();
					}
	
					$yymajor = self::YYNOCODE;
				}
			} else {
				$this->yy_accept();
				$yymajor = self::YYNOCODE;
			}
		} while ($yymajor != self::YYNOCODE && $this->stack->size());
		
		return;
	}
	
	/** 
	 * Destructors are all called for
	 * all stack elements before shutting the parser down.
	 *
	 */
	public function finalize() {
		while ($this->stack->size()) $this->yy_pop_parser_stack();
	}
	
	/**
	 * Get the name for a symbol
	 *
	 * @param int $i symbol index
	 * @return string Symbol name
	 */
	public function getSymbolName($i) {
		/* For tracing shifts, the names of all terminals and nonterminals
		** are required.  The following table supplies these names */
		$yyTokenName = array(
			  "$",             "TK_COMMA",      "TK_OR",         "TK_AND",      
			  "TK_IS",         "TK_EQUAL",      "TK_NOT_EQUAL",  "TK_GT",       
			  "TK_LT",         "TK_GE",         "TK_LE",         "TK_DOTDOT",   
			  "TK_PLUS",       "TK_MIN",        "TK_STAR",       "TK_SLASH",    
			  "TK_PERCENT",    "TK_NOT",        "TK_DOT",        "TK_ELSEIF",   
			  "TK_ELSE",       "TK_END",        "TK_SMURK",      "TK_MULTILINE_COMMENT",
			  "TK_COMMENT",    "TK_DOLLAR",     "TK_ID",         "TK_LBRACE",   
			  "TK_RBRACE",     "TK_LPAREN",     "TK_RPAREN",     "TK_LBRACKET", 
			  "TK_RBRACKET",   "TK_SILENT",     "TK_ESCAPES",    "TK_STRING",   
			  "TK_NUMBER",     "TK_COLON",      "TK_IF",         "TK_SET",      
			  "TK_LOCAL",      "TK_FOREACH",    "TK_IN",         "TK_STOP",     
			  "TK_INCLUDE",    "TK_PARSE",      "TK_DIRECTIVE",  "TK_MACRO",    
			  "TK_INTERPOLATE",  "error",         "input",         "top_block_list",
			  "block_list",    "block",         "escapes",       "reference",   
			  "directive",     "interpolated",  "comment",       "open_reference",
			  "braced_reference",  "simple_reference",  "silent",        "@1",          
			  "modifier_index_list",  "modifier_list",  "modifier",      "parameter_list",
			  "modifier_index",  "expr",          "scalar",        "array",       
			  "macro_call",    "ref_or_string",  "array_values",  "array_parameter_list",
			  "array_value",   "elseif_list",   "else_single",   "local_parameter_list",
			  "macro_def",     "macro_parameter_list",
		);
		
		return $yyTokenName[$i];
	}

	public function getRuleName($i) {
		
		/* For tracing reduce actions, the names of all rules are required.
		*/
		$yyRuleName = array(
			/*   0 */ "input ::= top_block_list",
			/*   1 */ "top_block_list ::= block_list",
			/*   2 */ "block_list ::= block_list block",
			/*   3 */ "block_list ::=",
			/*   4 */ "block ::= TK_SMURK",
			/*   5 */ "block ::= escapes reference",
			/*   6 */ "block ::= escapes directive",
			/*   7 */ "block ::= interpolated",
			/*   8 */ "block ::= comment",
			/*   9 */ "comment ::= TK_MULTILINE_COMMENT",
			/*  10 */ "comment ::= TK_COMMENT",
			/*  11 */ "reference ::= open_reference",
			/*  12 */ "reference ::= braced_reference",
			/*  13 */ "simple_reference ::= TK_DOLLAR silent TK_ID",
			/*  14 */ "@1 ::=",
			/*  15 */ "open_reference ::= TK_DOLLAR silent TK_ID @1 modifier_index_list modifier_list",
			/*  16 */ "braced_reference ::= TK_DOLLAR silent TK_LBRACE TK_ID modifier_index_list modifier_list TK_RBRACE",
			/*  17 */ "modifier_list ::= modifier_list TK_DOT modifier",
			/*  18 */ "modifier_list ::= modifier",
			/*  19 */ "modifier_list ::=",
			/*  20 */ "modifier ::= TK_ID TK_LPAREN parameter_list TK_RPAREN modifier_index_list",
			/*  21 */ "modifier ::= TK_ID modifier_index_list",
			/*  22 */ "modifier_index_list ::= modifier_index_list modifier_index",
			/*  23 */ "modifier_index_list ::=",
			/*  24 */ "modifier_index ::= TK_LBRACKET expr TK_RBRACKET",
			/*  25 */ "parameter_list ::= parameter_list TK_COMMA expr",
			/*  26 */ "parameter_list ::= expr",
			/*  27 */ "parameter_list ::=",
			/*  28 */ "silent ::=",
			/*  29 */ "silent ::= TK_SILENT",
			/*  30 */ "escapes ::= TK_ESCAPES",
			/*  31 */ "escapes ::=",
			/*  32 */ "expr ::= expr TK_OR expr",
			/*  33 */ "expr ::= expr TK_AND expr",
			/*  34 */ "expr ::= expr TK_PLUS expr",
			/*  35 */ "expr ::= expr TK_MIN expr",
			/*  36 */ "expr ::= expr TK_STAR expr",
			/*  37 */ "expr ::= expr TK_SLASH expr",
			/*  38 */ "expr ::= expr TK_PERCENT expr",
			/*  39 */ "expr ::= TK_NOT expr",
			/*  40 */ "expr ::= expr TK_EQUAL expr",
			/*  41 */ "expr ::= expr TK_NOT_EQUAL expr",
			/*  42 */ "expr ::= expr TK_GT expr",
			/*  43 */ "expr ::= expr TK_LT expr",
			/*  44 */ "expr ::= expr TK_GE expr",
			/*  45 */ "expr ::= expr TK_LE expr",
			/*  46 */ "expr ::= TK_LPAREN expr TK_RPAREN",
			/*  47 */ "expr ::= scalar",
			/*  48 */ "expr ::= open_reference",
			/*  49 */ "expr ::= array",
			/*  50 */ "expr ::= macro_call",
			/*  51 */ "expr ::= expr TK_DOT modifier_list",
			/*  52 */ "scalar ::= TK_STRING",
			/*  53 */ "scalar ::= TK_NUMBER",
			/*  54 */ "ref_or_string ::= open_reference",
			/*  55 */ "ref_or_string ::= TK_STRING",
			/*  56 */ "array ::= TK_LBRACKET array_values TK_RBRACKET",
			/*  57 */ "array_values ::= array_parameter_list",
			/*  58 */ "array_values ::= expr TK_DOTDOT expr",
			/*  59 */ "array_parameter_list ::= array_parameter_list TK_COMMA array_value",
			/*  60 */ "array_parameter_list ::= array_value",
			/*  61 */ "array_parameter_list ::=",
			/*  62 */ "array_value ::= expr",
			/*  63 */ "array_value ::= expr TK_COLON expr",
			/*  64 */ "directive ::= TK_IF TK_LPAREN expr TK_RPAREN block_list elseif_list else_single TK_END",
			/*  65 */ "elseif_list ::= elseif_list TK_ELSEIF TK_LPAREN expr TK_RPAREN block_list",
			/*  66 */ "elseif_list ::=",
			/*  67 */ "else_single ::= TK_ELSE block_list",
			/*  68 */ "else_single ::=",
			/*  69 */ "directive ::= TK_SET TK_LPAREN open_reference TK_IS expr TK_RPAREN",
			/*  70 */ "directive ::= TK_LOCAL TK_LPAREN local_parameter_list TK_RPAREN",
			/*  71 */ "local_parameter_list ::= local_parameter_list TK_COMMA simple_reference",
			/*  72 */ "local_parameter_list ::= simple_reference",
			/*  73 */ "directive ::= TK_FOREACH TK_LPAREN simple_reference TK_IN expr TK_RPAREN block_list else_single TK_END",
			/*  74 */ "directive ::= TK_STOP",
			/*  75 */ "directive ::= TK_INCLUDE TK_LPAREN ref_or_string TK_RPAREN",
			/*  76 */ "directive ::= TK_PARSE TK_LPAREN ref_or_string TK_RPAREN",
			/*  77 */ "directive ::= macro_call",
			/*  78 */ "macro_call ::= TK_DIRECTIVE TK_LPAREN parameter_list TK_RPAREN",
			/*  79 */ "directive ::= macro_def",
			/*  80 */ "macro_def ::= TK_MACRO TK_LPAREN TK_ID macro_parameter_list TK_RPAREN block_list TK_END",
			/*  81 */ "macro_parameter_list ::= macro_parameter_list simple_reference",
			/*  82 */ "macro_parameter_list ::=",
			/*  83 */ "interpolated ::= TK_INTERPOLATE TK_LBRACE expr TK_RBRACE",
		);
		
		return $yyRuleName[$i];
	}
}
?>